package Equipment;

import java.awt.Color;

import Items.Gear.Gear;
import DisplayText.DisplayText;

/**
 * Base EquipSlot Class.
 * @author Phil
 * 09/02/2012
 */
public class EquipSlot 
{
	protected int slotID;
	protected String slotName; 
	protected Gear equippedItem;
	
	/**
	 * Constructor
	 */
	public EquipSlot(String slotName, int slotID)
	{
		this.slotName = slotName;
		this.slotID = slotID;
	}
	
	
	/**
	 * Equips an item.
	 * @param which Gear Object to Equip
	 * @return Boolean based on whether or not the item is successfully equipped.
	 */
	public void equipGear(Gear which)
	{
		//Check to see if this gear can be equiped.
		if(which.getEquipSlot() == slotID)
		{
			if(gearEquipped())
			{
				unequipGear();
			}
			
			equippedItem = which;
		}
		else
		{
			DisplayText.displayText("Can't equip that item.", Color.RED);
		}
	}
	 
	
	/**
	 * Unequips an item.
	 * @param which Gear object to unequip
	 * @return Boolean based on whether or not the item is successfully unequipped.
	 */
	public Boolean unequipGear()
	{
		equippedItem = null;
		return true;
	}
	
	
	/**
	 * Checks if gear is equipped.
	 * @return Boolean based on whether or not item is currently equipped.
	 */
	public Boolean gearEquipped()
	{
		//TODO: Logic to check if this item is equipped.
		return equippedItem != null;
	}
	
	public Gear getEquipedGear()
	{
		return equippedItem;
	}
	
	
	/**
	 * Generates string to append for saving this gear layout
	 * @return String to save to file.
	 */
	public String saveSlot()
	{
		String outputString = "";
		//TODO: Logic to build output string
		return outputString;
	}
	
	
	/**
	 * Method to load up gear into some slot based on incoming string.
	 * @param incString
	 */
	public void loadSlot(String incString)
	{
		//TODO: Logic to build input string & instantiate object.
	}
	
	
}
